#ifndef CAPTCHAASSISTTASK_H
#define CAPTCHAASSISTTASK_H

#include "libs/base/task/task.h"
#include <QPointer>

class CaptchaAssistDialog;
class LiveRecorder;

class CaptchaAssistTask : public yc::Task
{
    Q_OBJECT
public:
    explicit CaptchaAssistTask(LiveRecorder* recorder, QObject* parent = nullptr);

private:
    void startImpl() override;
    void terminateImpl() override;
    void startRequest();
    void startNext();
    void onCaptchaStateChanged(bool passed);

    static QString getAnchorId(int index);

    LiveRecorder* recorder_;
    int step_count_ = 0;
    int success_count_ = 0;
    int pos_ = 0;
    QTimer* captcha_timer_ = nullptr;
    bool captcha_shown_ = false;
    int captcha_retry_ = 0;
    int reload_retry_ = 0;
    QTimer* reload_timer_ = nullptr;
    QPointer<CaptchaAssistDialog> dialog_;
};

#endif // CAPTCHAASSISTTASK_H
